import axios from "axios";
import {config} from "webpack";

/*axios({
    method: 'GET',
    url: 'http://localhost:8888/getT',
    params: {
        "a": "1",
        "b": "2",
    }
}).then(res => {
    console.log(res)
})

axios({
    method: 'POST',
    url: 'http://localhost:8888/postT',
    headers: {
        'Content-Type':'application/x-www-form-urlencoded'
    },
    data: {
        a: "1",
        b: "2",
    }
}).then(res => {
    console.log(res)
})*/

/*axios.all([
    axios({
        method: 'GET',
        url: 'http://localhost:8888/getT',
        params: {
            "a": "1",
            "b": "2",
        }
    }),
    axios({
        method: 'POST',
        url: 'http://localhost:8888/postT',
        headers: {
            'Content-Type':'application/x-www-form-urlencoded'
        },
        data: {
            a: "1",
            b: "2",
        }
    })
]).then(res=>{
    console.log(res);
}).catch(err => console)*/

/*axios.defaults.baseURL="http://localhost:8888";
axios.defaults.timeout=3000;

axios.all([
    axios({
        method: 'GET',
        url: 'getT',
        params: {
            "a": "1",
            "b": "2",
        }
    }),
    axios({
        method: 'POST',
        url: 'postT',
        headers: {
            'Content-Type':'application/x-www-form-urlencoded'
        },
        data: {
            a: "1",
            b: "2",
        }
    })
]).then(
    axios.spread((res1,res2)=>{
        console.log(res1);
        console.log(res2);
    })
).catch(err => console)*/

axios.defaults.baseURL="http://localhost:8888";
axios.defaults.timeout=3000;

let eduwork = axios.create({
    baseURL: "http://api.eduwork.cn/admin",
    timeout: 5000
})

let local1 = axios.create({
    baseURL: "http://localhost:8888",
    timeout: 3000
})

eduwork.get(
    'link?id=1'
).then(res => {
    console.log(res)
}).catch(err=>{
    console.log("--------------error-----------------");
    console.log(err);
})

// local1.interceptors.request.use(config=>{
//     console.log("request is ok")
//     return config
// },error => {
//     console.log(error)
// })

// local1.interceptors.response.use(config=>{
//     console.log("response is ok")
//     return config.data
// },error => {
//     console.log(error)
// })

axios.get(
    'getT',{"a": "1", "b": "2"}
).then(res => {
    console.log(res)
})
